﻿using Compiler.Modules;
using System;
using System.IO;

namespace Compiler
{
    class Parser
    {
        public Parser(string fileName)
        {
            var preProc = new Preprocessor();
            var code = Load(fileName);
            preProc.Run(code);

            //Invoke compiler
            var compiler = new Modules.Compiler();
        }

        public string[] Load(string fileName)
        {
            if (fileName.Length == 0)
            {
                throw new Exception("No Source File");
            }
            Hub.SetSource(fileName);

            var sr = new StreamReader(fileName);
            var allCode = sr.ReadToEnd();
            sr.Close();

            return allCode.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
        }

    }
}
